package com.spring.demo7;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
	
	/**
	 * SpringAop 基于Aop的xml架构
	 */
	public void testDemo(){
		ApplicationContext context = new ClassPathXmlApplicationContext("bean7_aop_xml.xml");
		//student是目标对象(target object):实际运行时，springAop采用代理实现，实际上aop操作的是目标对象产生的代理对象
		Student student = (Student) context.getBean("student");
		student.getName();//连接点：程序执行过程中的某一行为 Joinpoint
		student.getAge();
		//student.printThrowException();
	}
	/**
	 * SpringAop 基于 AOP的 @AspectJ
	 */
	public void testDemo2(){
		ApplicationContext context = new ClassPathXmlApplicationContext("bean7_aop_AspectJ.xml");
		Student student = (Student) context.getBean("student");
		student.getName();
		student.getAge();
		//student.printThrowException();
	}
	public static void main(String[] args) {
		new MainApp().testDemo();
		System.out.println("========");
		new MainApp().testDemo2();
	}
}
